package com.qf.action;

import com.qf.exception.YunException;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Controller
public class ZhiFuAction extends BaseAction {
    @ResponseBody
    @RequestMapping("/zhifu.do")
    public Map<String,Object> zhifu(HttpServletRequest request) throws YunException {
        Map<String ,Object> map = new ConcurrentHashMap<>();
        //获取页面传递过来的数据
        String money = request.getParameter("money");
        //后端判断,常规情况后端是不需要做判断的
        if(StringUtils.isEmpty(money)){//从程序健壮性的角度去考虑问题
            //业务其实已经不完善
            throw new YunException("money参数有误",-13);
        }
        try {
            int i = 1/0;
            System.out.println(i);
        } catch (Exception e) {
            e.printStackTrace();
            throw  new YunException("排队中",-2);
        }

        map.put("code",0);
        map.put("message","支付成功");
        return map;
    }
}
